﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using ZLDC.Common.Estate;
namespace ZLDC.Estate.Quantify
{
    public partial class lp_Basis : _PageBase
    {
        public StringBuilder sb = new StringBuilder();
        protected string typename = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            GetTB();
            if (!IsPostBack)
            {
                if (Request.QueryString["typename"] != null)
                {
                    typename=Request.QueryString["typename"].ToString();
                    if (typename != "")
                    {
                        GetList(typename);
                    }
                }
            }
        }
        protected void GetList(string typename)
        {
            DataSet ds = new DataSet();
            if (typename == "fk")
            {
                Button2.Enabled = false;
                ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds("select * from lp_Basis ");
            }
            else
            {
                txtTypeName.Text = typename;
                ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds("select * from lp_Basis where TypeName='" + typename + "'");
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                sb.Append( "<tr>");
                sb.Append("<td>");
                sb.Append("<input type=\"text\" class=\"txtwidth\"  name=\"txtCode\" value='" + ds.Tables[0].Rows[i]["TypeCode"] + "' />");
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append("<input type=\"text\"  name=\"txtName\" value='" + ds.Tables[0].Rows[i]["Name"] + "' />");
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append("<input type=\"text\" class=\"txtwidth\" name=\"txtPoint\" onkeydown=\"myKeyDown()\" value='" + ds.Tables[0].Rows[i]["Point"] + "' />");
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append("<input type=\"text\"  name=\"txtRemark\" value='" + ds.Tables[0].Rows[i]["Remark"] + "' />");
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append("<input type=\"text\"  name=\"txtNum\" value='" + ds.Tables[0].Rows[i]["Quantity"] + "' onkeydown=\"myKeyDown()\"/>");
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append("<input type=\"text\" class=\"txtwidth\" name=\"txtUnit\" value='" + ds.Tables[0].Rows[i]["Unit"] + "' />");
                sb.Append("</td>");
                sb.Append("<td>");
                sb.Append("<input type=\"text\" name=\"txtHighest\" class=\"txtwidth\" onkeydown=\"myKeyDown()\" value='" + ds.Tables[0].Rows[i]["Highest"] + "' />");
                sb.Append("</td>"); 
                sb.Append("<td>");
                sb.Append("<input type=\"text\" name=\"txtSort\" class=\"txtwidth\" onkeydown=\"myKeyDown()\" value='" + ds.Tables[0].Rows[i]["Sort"] + "' />");
                sb.Append("</td>"); 
                sb.Append("<td>");
                //string fk = ds.Tables[0].Rows[i]["dte"].ToString() == "1" ? "checked=\"checked\"" : "";
                //sb.Append("<input name=\"ckDe\" type=\"checkbox\"  class=\"txtwidth\" "+fk+" />");
                sb.Append("<input    type='button'  value='删除' onclick=\"delRow(this,'tb1')\" />");
                sb.Append("</td>");
                sb.Append ("<tr>");
            }
          
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (Request.Form["txtName"] != null)
            {
                string[] txtName = Request.Form["txtName"].Split(',');//分值项
                string TypeName = txtTypeName.Text;//类别
                string[] txtCode = Request.Form["txtCode"].Split(',');//编码
                string[] txtPoint = Request.Form["txtPoint"].Split(',');//分
                string[] txtRemark = Request.Form["txtRemark"].Split(',');//备注
                string[] txtNum = Request.Form["txtNum"].Split(',');//数量
                string[] txtSort = Request.Form["txtSort"].Split(',');//排序
                string[] txtHighest = Request.Form["txtHighest"].Split(',');//最高分
                string[] txtUnit = Request.Form["txtUnit"].Split(',');//最高分
                //string[] dte;
               
                string msg = ZLDC.Topo.BLL.Estate.lp_Basis.SqlQuery(txtName, TypeName, txtCode, txtPoint, txtRemark, txtNum, txtSort, txtHighest,txtUnit);
                Response.Write("<script>alert('"+msg+"');window.location.href=location.href;</script>");
            }
        }
        protected void GetTB()
        {
            string ht;
            ht = ZLDC.Topo.BLL.Estate.lp_Basis.GetTB("select TypeName from lp_Basis group by TypeName");
            divht.InnerHtml = ht;
        }

    }
}
